package com.houweishi.module.product.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.product.domain.BizProductModel;
import com.houweishi.module.product.service.IBizProductModelService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 物品类型Controller
 * 
 * @author houweishi
 * @date 2023-02-25
 */
@RestController
@RequestMapping("/module/productmodel")
public class BizProductModelController extends BaseController
{
    @Autowired
    private IBizProductModelService bizProductModelService;

    /**
     * 查询物品类型列表
     */
    @PreAuthorize("@ss.hasPermi('module:productmodel:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizProductModel bizProductModel)
    {
        startPage();
        List<BizProductModel> list = bizProductModelService.selectBizProductModelList(bizProductModel);
        return getDataTable(list);
    }

    /**
     * 导出物品类型列表
     */
    @PreAuthorize("@ss.hasPermi('module:productmodel:export')")
    @Log(title = "物品类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizProductModel bizProductModel)
    {
        List<BizProductModel> list = bizProductModelService.selectBizProductModelList(bizProductModel);
        ExcelUtil<BizProductModel> util = new ExcelUtil<BizProductModel>(BizProductModel.class);
        util.exportExcel(response, list, "物品类型数据");
    }

    /**
     * 获取物品类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:productmodel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizProductModelService.selectBizProductModelById(id));
    }

    /**
     * 新增物品类型
     */
    @PreAuthorize("@ss.hasPermi('module:productmodel:add')")
    @Log(title = "物品类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizProductModel bizProductModel)
    {
        return toAjax(bizProductModelService.insertBizProductModel(bizProductModel));
    }

    /**
     * 修改物品类型
     */
    @PreAuthorize("@ss.hasPermi('module:productmodel:edit')")
    @Log(title = "物品类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizProductModel bizProductModel)
    {
        return toAjax(bizProductModelService.updateBizProductModel(bizProductModel));
    }

    /**
     * 删除物品类型
     */
    @PreAuthorize("@ss.hasPermi('module:productmodel:remove')")
    @Log(title = "物品类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizProductModelService.deleteBizProductModelByIds(ids));
    }
}
